<%--
  Created by IntelliJ IDEA.
  User: Li Chuanwei
  Date: 2023-07-12
  Time: 15:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hello, World</title>
    <style type="text/css">
        html{height:100%}
        body{height:100%;margin:0px;padding:0px}
        #container{height:100%}
    </style>
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=XXAR8BzqXpGGRi9VbWVb5X0TUuYAc6Qb">
    </script>
</head>

<body>
<div id="container"></div>
<script type="text/javascript">
    var address = "${address}";
    var lng ;
    var lat ;
    var script = document.createElement('script');
    script.src = 'https://api.map.baidu.com/geocoding/v3/?address=' + address + '&output=json&ak=Gkl6rkGh60cejjMtFiHgPfIcg2NGr0DP&callback=handleResponse';
    document.head.appendChild(script);

    function handleResponse(data) {
        // 在这里处理响应数据
        lng = data.result.location.lng;
        lat = data.result.location.lat;
        var map = new BMapGL.Map("container");
        // 创建地图实例

        var point = new BMapGL.Point(lng, lat);
        // 创建点坐标
        map.centerAndZoom(point, 15);
        // 初始化地图，设置中心点坐标和地图级别
        map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
        var marker = new BMapGL.Marker(point);        // 创建标注
        map.addOverlay(marker);                     // 将标注添加到地图中
    }

</script>
</body>
</html>
